import request from '@/utils/request'

// 获取权限树
export function getPermission() {
  return request({
    url: '/permission/0',
    method: 'get'
  })
}

// 根据角色获取权限id列表
export function getRolePermission(roleId) {
  return request({
    url: `/permission/role/${roleId}`,
    method: 'get'
  })
}

//给角色添加权限信息
export function addRolePermission(roleId, data) {
  return request({
    url: `/permission/role/${roleId}`,
    method: 'post',
    data
  })
}

export function addPermission(data) {
  return request({
    url: '/permission',
    method: 'post',
    data
  })
}

export function modifyPermission(id, data) {
  return request({
    url: `/permission/${id}`,
    method: 'put',
    data
  })
}

export function deletePermission(id, status) {
  return request({
    url: `/permission/status/${id}?status=${status}`,
    method: 'put'
  })
}
